package cn.bluarry.donationuser.Respose;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;


import java.io.Serializable;

import static cn.bluarry.donationuser.util.Utils.getUUID;


@JsonInclude(JsonInclude.Include.NON_NULL)
public class UserResponse<T> implements Serializable {
    private String resquestid;
    private T user;

    private Integer code;
    private String msg;

    public UserResponse(String resquestid, T user) {
        this.resquestid = resquestid;
        this.user = user;
    }
    public UserResponse(String resquestid) {
        this.resquestid = resquestid;
    }

    public UserResponse(T user) {
        this.code=null;
        this.msg=null;
        this.resquestid = getUUID();
        this.user = user;
    }

    public UserResponse(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    @JsonProperty("ResquestId")
    public String getResquestid() {
        return resquestid;
    }

    public void setResquestid(String resquestid) {
        this.resquestid = resquestid;
    }

    @JsonProperty("User")
    public T getUser() {
        return user;
    }

    public void setUser(T user) {
        this.user = user;
    }

    public static <T> UserResponse<T> createByerrorMsg(String msg){
        return new UserResponse<>(-1,msg);
    }




}
